<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<h1>User LIST</h1>


<a href="<%=request.getContextPath()%>/users/add" 
class="btn btn-sm btn-primary" 
data-loading-text="Loading" id="addBtn">新增</a>


<table class="table table-striped table-bordered">
	<tr>
		<th style="width:120px">功能</th>
		<th>帳號</th>
		<th>姓名</th>
		<th>電話</th>
	</tr>
	<c:forEach items="${users}" var="item">
		<tr>
			<td>
		
			<a href="<%=request.getContextPath()%>/users/edit?id=${item.id}" 
class="btn btn-sm btn-success" 
data-loading-text="Loading" id="editBtn">編輯</a>
			<a href="<%=request.getContextPath()%>/users/delete?id=${item.id}" 
			class="btn btn-sm btn-danger" 
			data-loading-text="Loading" id="delBtn">刪除</a>				
		
		</td>
		<td>${item.account} </td>
		<td> ${item.name} </td>
		<td>
		<% try { %>
			<c:forEach items="${item.phones}" var="phone">
				${phone.phone} <br/>
			</c:forEach>
		<% 
			} catch (org.hibernate.LazyInitializationException ex) {
				out.println("當你看到這一行字, 代表發生 LazyInitialization 例外, 請在 web.xml 增加 OpenSessionInView 的 Filter");		
			}
		%>
		</td>
	</tr>
</c:forEach>
</table>

